|
1
|
|
|
/** |
|
2
|
|
|
* Nextcloud - passman |
|
3
|
|
|
* |
|
4
|
|
|
* @copyright Copyright (c) 2016, Sander Brand ([email protected]) |
|
5
|
|
|
* @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected]) |
|
6
|
|
|
* @license GNU AGPL version 3 or any later version |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
11
|
|
|
* License, or (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
(function () { |
|
24
|
|
|
'use strict'; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @ngdoc overview |
|
28
|
|
|
* @name passmanApp |
|
29
|
|
|
* @description |
|
30
|
|
|
* # passmanApp |
|
31
|
|
|
* |
|
32
|
|
|
* Main module of the application. |
|
33
|
|
|
*/ |
|
34
|
|
|
angular |
|
35
|
|
|
.module('passmanApp', [ |
|
36
|
|
|
'ngAnimate', |
|
37
|
|
|
'ngCookies', |
|
38
|
|
|
'ngResource', |
|
39
|
|
|
'ngRoute', |
|
40
|
|
|
'ngSanitize', |
|
41
|
|
|
'ngTouch', |
|
42
|
|
|
'templates-main', |
|
43
|
|
|
'LocalStorageModule', |
|
44
|
|
|
'offClick', |
|
45
|
|
|
'ngPasswordMeter', |
|
46
|
|
|
'ngclipboard', |
|
47
|
|
|
'xeditable', |
|
48
|
|
|
'ngTagsInput', |
|
49
|
|
|
'angularjs-datetime-picker', |
|
50
|
|
|
'ui.sortable' |
|
51
|
|
|
]) |
|
52
|
|
|
.config(function ($routeProvider) { |
|
53
|
|
|
$routeProvider |
|
54
|
|
|
.when('/', { |
|
55
|
|
|
templateUrl: 'views/vaults.html', |
|
56
|
|
|
controller: 'VaultCtrl' |
|
57
|
|
|
}) |
|
58
|
|
|
.when('/vault/:vault_id', { |
|
59
|
|
|
templateUrl: 'views/show_vault.html', |
|
60
|
|
|
controller: 'CredentialCtrl' |
|
61
|
|
|
}) |
|
62
|
|
|
.when('/vault/:vault_id/new', { |
|
63
|
|
|
templateUrl: 'views/edit_credential.html', |
|
64
|
|
|
controller: 'CredentialEditCtrl' |
|
65
|
|
|
}) |
|
66
|
|
|
.when('/vault/:vault_id/edit/:credential_id', { |
|
67
|
|
|
templateUrl: 'views/edit_credential.html', |
|
68
|
|
|
controller: 'CredentialEditCtrl' |
|
69
|
|
|
}).when('/vault/:vault_id/:credential_id/share', { |
|
70
|
|
|
templateUrl: 'views/share_credential.html', |
|
71
|
|
|
controller: 'ShareCtrl' |
|
72
|
|
|
}).when('/vault/:vault_id/:credential_id/revisions', { |
|
73
|
|
|
templateUrl: 'views/credential_revisions.html', |
|
74
|
|
|
controller: 'RevisionCtrl' |
|
75
|
|
|
}) |
|
76
|
|
|
.when('/vault/:vault_id/settings', { |
|
77
|
|
|
templateUrl: 'views/settings.html', |
|
78
|
|
|
controller: 'SettingsCtrl' |
|
79
|
|
|
}) |
|
80
|
|
|
.otherwise({ |
|
81
|
|
|
redirectTo: '/' |
|
82
|
|
|
}); |
|
83
|
|
|
}).config(['$httpProvider', function ($httpProvider) { |
|
84
|
|
|
$httpProvider.defaults.headers.common.requesttoken = oc_requesttoken; |
|
|
|
|
|
|
85
|
|
|
}]).config(function (localStorageServiceProvider) { |
|
86
|
|
|
localStorageServiceProvider |
|
87
|
|
|
.setNotify(true, true); |
|
88
|
|
|
}); |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* jQuery for notification handling D: |
|
92
|
|
|
**/ |
|
93
|
|
|
jQuery(document).ready(function () { |
|
94
|
|
|
var findItemByID = function (id) { |
|
95
|
|
|
var credentials, foundItem = false; |
|
96
|
|
|
credentials = angular.element('#app-content-wrapper').scope().credentials; |
|
97
|
|
|
angular.forEach(credentials, function (credential) { |
|
98
|
|
|
if (credential.credential_id === id) { |
|
99
|
|
|
foundItem = credential; |
|
100
|
|
|
} |
|
101
|
|
|
}); |
|
102
|
|
|
return foundItem; |
|
103
|
|
|
}; |
|
104
|
|
|
jQuery(document).on('click', '.undoDelete', function () { |
|
105
|
|
|
var credential = findItemByID($(this).attr('data-item-id')); |
|
106
|
|
|
angular.element('#app-content-wrapper').scope().recoverCredential(credential); |
|
107
|
|
|
//Outside anglular we need $apply |
|
108
|
|
|
angular.element('#app-content-wrapper').scope().$apply(); |
|
109
|
|
|
}); |
|
110
|
|
|
jQuery(document).on('click', '.undoRestore', function () { |
|
111
|
|
|
var credential = findItemByID($(this).attr('data-item-id')); |
|
112
|
|
|
angular.element('#app-content-wrapper').scope().deleteCredential(credential); |
|
113
|
|
|
//Outside anglular we need $apply |
|
114
|
|
|
angular.element('#app-content-wrapper').scope().$apply(); |
|
115
|
|
|
}); |
|
116
|
|
|
var adjustControlsWidth = function (r) { |
|
|
|
|
|
|
117
|
|
|
if ($('#controls').length) { |
|
118
|
|
|
var controlsWidth; |
|
119
|
|
|
// if there is a scrollbar … |
|
120
|
|
|
if ($('#app-content').get(0)) { |
|
121
|
|
|
if ($('#app-content').get(0).scrollHeight > $('#app-content').height()) { |
|
122
|
|
|
if ($(window).width() > 768) { |
|
123
|
|
|
controlsWidth = $('#content').width() - $('#app-navigation').width() - OC.Util.getScrollBarWidth(); |
|
124
|
|
|
if (!$('#app-sidebar').hasClass('hidden') && !$('#app-sidebar').hasClass('disappear')) { |
|
125
|
|
|
controlsWidth -= $('#app-sidebar').width(); |
|
126
|
|
|
} |
|
127
|
|
|
} else { |
|
128
|
|
|
controlsWidth = $('#content').width() - OC.Util.getScrollBarWidth(); |
|
129
|
|
|
} |
|
130
|
|
|
} else { // if there is none |
|
131
|
|
|
if ($(window).width() > 768) { |
|
132
|
|
|
controlsWidth = $('#content').width() - $('#app-navigation').width(); |
|
133
|
|
|
if (!$('#app-sidebar').hasClass('hidden') && !$('#app-sidebar').hasClass('disappear')) { |
|
134
|
|
|
//controlsWidth -= $('#app-sidebar').width(); |
|
135
|
|
|
} |
|
136
|
|
|
} else { |
|
137
|
|
|
controlsWidth = $('#content').width(); |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
var magic; |
|
142
|
|
|
if (r) { |
|
143
|
|
|
magic = 0; |
|
144
|
|
|
} else { |
|
145
|
|
|
magic = 85; |
|
146
|
|
|
} |
|
147
|
|
|
$('#controls').css('width', controlsWidth + magic); |
|
|
|
|
|
|
148
|
|
|
$('#controls').css('min-width', controlsWidth + magic); |
|
149
|
|
|
} |
|
150
|
|
|
}; |
|
151
|
|
|
/* |
|
152
|
|
|
$(window).resize(adjustControlsWidth, 400); |
|
153
|
|
|
setTimeout(function () { |
|
154
|
|
|
adjustControlsWidth(true); |
|
155
|
|
|
}, 200);*/ |
|
156
|
|
|
|
|
157
|
|
|
//@Fack this |
|
158
|
|
|
/* |
|
159
|
|
|
$(document).on('click', '#app-navigation-toggle', function () { |
|
160
|
|
|
setTimeout(function () { |
|
161
|
|
|
if ($('#app-content').css('transform').toString().indexOf('matrix') >= 0) { |
|
162
|
|
|
$('#passman-controls').css('width', 'calc( 100% - 245px)'); |
|
163
|
|
|
$('#passman-controls').css('top', '0'); |
|
164
|
|
|
} else { |
|
165
|
|
|
$('#passman-controls').css('left', 0); |
|
166
|
|
|
$('#passman-controls').css('top', '44px'); |
|
167
|
|
|
$('#passman-controls').css('width', '100%'); |
|
168
|
|
|
} |
|
169
|
|
|
}, 350); |
|
170
|
|
|
});*/ |
|
171
|
|
|
}); |
|
172
|
|
|
}()); |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.